package thread;

public class Demo41 {

    private static int total = 0;

    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                int sum = 0;
                for (int i = 0; i <= 100; i++) {
                    sum += i;
                }
                total = sum;
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
        thread.join();
        System.out.println("total = "+total);
    }
}
